feat: Support optional spanKind override for InvokeAgentScope and ExecuteToolScope#213
Merged
nikhilNava merged 4 commits intomainfrom Mar 16, 2026
Merged
Conversation
…cope Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
nikhilNava
March 16, 2026 15:14
View session
Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>
…ders, update FormatLogData with Kind default Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an optional span kind override capability to the runtime tracing scopes while also introducing a string-based span kind representation for DTO/log export to avoid taking a dependency on System.Diagnostics.ActivityKind in DTOs/builders.
Changes:
- Add optional
spanKindoverride parameter toInvokeAgentScope.Start(defaultClient) andExecuteToolScope.Start(defaultInternal). - Introduce
SpanKindConstantsand plumbSpanKindthroughBaseData, operation DTOs, and DTO builders as astring?. - Extend
ExportFormatter.FormatLogDataand tests to emit/validate aKindfield, defaulting toClientwhenSpanKindis unset.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Observability/Runtime/Tracing/Scopes/InvokeAgentScope.cs | Adds spanKind override support (defaults to Client). |
| src/Observability/Runtime/Tracing/Scopes/ExecuteToolScope.cs | Adds spanKind override support (defaults to Internal). |
| src/Observability/Runtime/DTOs/SpanKindConstants.cs | New string constants for span kind values. |
| src/Observability/Runtime/DTOs/BaseData.cs | Adds SpanKind as string? and includes it in ToDictionary(). |
| src/Observability/Runtime/DTOs/InvokeAgentData.cs | Threads spanKind through to base DTO. |
| src/Observability/Runtime/DTOs/ExecuteToolData.cs | Threads spanKind through to base DTO. |
| src/Observability/Runtime/DTOs/Builders/InvokeAgentDataBuilder.cs | Adds passthrough spanKind parameter to builder. |
| src/Observability/Runtime/DTOs/Builders/ExecuteToolDataBuilder.cs | Adds passthrough spanKind parameter to builder. |
| src/Observability/Runtime/Common/ExportFormatter.cs | Adds Kind to formatted log payload with a default. |
| src/Tests/.../Tracing/Scopes/InvokeAgentScopeTest.cs | Adds tests for default/overridden Activity.Kind. |
| src/Tests/.../Tracing/Scopes/ExecuteToolScopeTest.cs | Adds tests for default/overridden Activity.Kind. |
| src/Tests/.../DTOs/InvokeAgentDataTests.cs | Adds tests for DTO SpanKind default/override. |
| src/Tests/.../DTOs/ExecuteToolDataTests.cs | Adds tests for DTO SpanKind default/override. |
| src/Tests/.../DTOs/Builders/InvokeAgentDataBuilderTests.cs | Adds tests for builder spanKind passthrough. |
| src/Tests/.../DTOs/Builders/ExecuteToolDataBuilderTests.cs | Adds tests for builder spanKind passthrough. |
| src/Tests/.../DTOs/BaseDataTests.cs | Adds tests for base DTO SpanKind + dictionary inclusion. |
| src/Tests/.../Common/ExportFormatterTests.cs | Adds assertions for Kind in log JSON output. |
You can also share your feedback on Copilot code review. Take the survey.
...sts/Microsoft.Agents.A365.Observability.Runtime.Tests/Tracing/Scopes/InvokeAgentScopeTest.cs
Show resolved
Hide resolved
threddy
approved these changes
Mar 16, 2026
fpfp100
approved these changes
Mar 16, 2026
nikhilNava
approved these changes
Mar 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SpanKindConstantsclass with string constants (Server, Client, Producer, Consumer, Internal)BaseData: ChangeActivityKind? SpanKindtostring? SpanKindInvokeAgentData: ChangeActivityKind?tostring?, removeSystem.DiagnosticsimportExecuteToolData: ChangeActivityKind?tostring?, removeSystem.DiagnosticsimportInvokeAgentDataBuilder: ChangeActivityKind?tostring?, removeSystem.DiagnosticsimportExecuteToolDataBuilder: ChangeActivityKind?tostring?, removeSystem.DiagnosticsimportExportFormatter.FormatLogData(): IncludeKindfield, default toSpanKindConstants.Clientwhen nullSpanKindConstantsstring values instead ofActivityKindenumFormatLogDatatests to verifyKindin JSON output✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.